const { User } = require("../database/sequlize");

// 获取所有用户
exports.getAllUsers = async () => {
  return await User.findAll();
};

// 根据id获取用户
exports.getUserById = async (id) => {
  return await User.findByPk(id);
};

// 创建用户
exports.createUser = async (newUserData) => {
  return User.create(newUserData);
};

// 更新用户信息
exports.updateUser = async (id, updatedUserData) => {
  await User.update(updatedUserData, {
    where: { id },
  });
  return await User.findByPk(id);
};

// 删除用户
exports.deleteUser = async (id) => {
  return await User.destroy({
    where: { id },
  });
};
